home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / DELPHI3.EXE / %MAINDIR% / Examples / Delphi3 / Console Chart Application / Teeconso.dpr < prev    next >
Encoding:
Text File  |  1998-11-17  |  1.7 KB  |  73 lines

  1. {******************************************}
  2. { TeeChart as a Console Application        }
  3. { Copyright (c) 1997 by David Berneda      }
  4. {    All Rights Reserved                   }
  5. {******************************************}
  6. program TeeConso;
  7.  
  8. {$IFDEF WIN32}
  9. {$APPTYPE CONSOLE}
  10. {$ENDIF}
  11.  
  12. { This project is a console application, with no
  13.   visual interface and no TForms.
  14.  
  15.   If you run this project, you'll see nothing
  16.   appears on screen !!
  17.  
  18.   It creates a TChart component on-the-fly, and
  19.   saves it as a bitmap image file: "c:\bar.bmp"
  20.  
  21.   The following "CreateChart" procedure can be
  22.   used inside CGI applications, and overcomes the
  23.   problem of no having a Parent for the Chart.
  24.  
  25.   The "trick" is to use a temporary invisible TForm
  26.   component and set Chart1.Parent to it.
  27. }
  28. uses
  29.   Forms,
  30.   Chart,
  31.   Series,
  32.   SysUtils,
  33.   ExtCtrls ;
  34.  
  35. {$R *.RES}
  36.  
  37. Procedure CreateChart;
  38. Var Chart1:TChart;
  39.     Form1:TForm;
  40.     Bar:TBarSeries;
  41. begin
  42.   Form1:=TForm.Create(nil);  { <-- fake parent }
  43.   try
  44.     Chart1:=TChart.Create(Form1);  { <-- create Chart1 }
  45.     try
  46.       Chart1.Parent:=Form1;  { <-- set fake parent }
  47.  
  48.       Bar:=TBarSeries.Create(Chart1);  { <-- create Series }
  49.       Chart1.AddSeries( Bar );   { <-- add to Chart1 }
  50.       Bar.FillSampleValues(10);   { <-- some values... }
  51.  
  52.       { Now we can , for example, save the
  53.         Chart to a bitmap image file.
  54.       }
  55.       Chart1.SaveToBitmapFile('c:\bar.bmp');  { <-- save ! }
  56.     finally
  57.       Chart1.Free;
  58.     end;
  59.   finally
  60.     Form1.Free;
  61.   end;
  62. end;
  63.  
  64. begin
  65.   try
  66.     CreateChart;
  67.   except
  68.     on E:Exception do  { just in case something fails... }
  69.        Application.ShowException(E);
  70.   end;
  71.   Application.Run;
  72. end.
  73.